package com.sunlands.deskmate.common.hystrix;

import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy;
import com.sunlands.deskmate.common.thread.MdcRunable;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.concurrent.Callable;

@Slf4j
@Primary
@Service
public class HystrixConcurrencyStrategyDecorator extends HystrixConcurrencyStrategy {
    @Override
    public <T> Callable<T> wrapCallable(Callable<T> callable) {
        return super.wrapCallable(MdcRunable.wrap(callable, MDC.getCopyOfContextMap()));
    }
}
